using System;
using UnityEngine;
namespace DefaultNamespace
{
    public enum EnemyState
    {
        Flee = 0,
        Attack = 1,
    }
    /// <summary>
    ///  使用示例  
    // enemyAI.SetBehavior(() =>
    // {
    //     if (health < 30) return EnemyState.Flee;
    //     return EnemyState.Attack;
    // });
    /// </summary>
    public class EnemyAI : MonoBehaviour
    {
        private Func<EnemyState> _currentBehavior;
        public void SetBehavior(Func<EnemyState> behavior)
        {
            _currentBehavior = behavior;
        }
        void Update()
        {
            var state = _currentBehavior?.Invoke();
            // 根据 state 执行动作  
            switch (state)
            {
                case EnemyState.Flee:
                    break;
                case EnemyState.Attack:
                    break;
            }
        }
    }
}